﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using Microsoft.Xna.Framework.Graphics;

namespace Nexxt.Pipeline.GameObjectContentProcessor

{
    /// <summary>
    /// Serializes a Game Object in a inary form to use within the framework
    /// </summary>
    [ContentTypeWriter]
    public class GameObjectTypeWriter : ContentTypeWriter<GameObjectContent>
    {
        /// <summary>
        /// Writes the contents of the GameObject
        /// </summary>
        /// <param name="output">The ContentWriter to write the object</param>
        /// <param name="value">The oject to be written</param>
        protected override void Write(ContentWriter output, GameObjectContent value)
        {
            output.Write(value.Name);
            output.Write(value.IsActive);
            output.Write(value.IsCollectable);
            output.Write(value.IsMovable);
            output.WriteExternalReference(value.Texture);
            output.Write(value.Position);
        }

        /// <summary>
        /// Gets the name of this type writer
        /// </summary>
        /// <param name="targetPlatform">The target platform of this compilation</param>
        /// <returns>A string representing the type writer</returns>
        public override string GetRuntimeReader(Microsoft.Xna.Framework.TargetPlatform targetPlatform)
        {
            return "Nexxt.Framework.TypeReaders.GameObjectTypeReader, Nexxt.Framework";
        }
    }
}
